<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: false, b: true, c: false, d: false, e: false, f: false }"
      ></navigationHeTong>
      <div v-if="zhiShow == '1'" class="boxsty zhiBiao">
        <!-- <div class="flex justifyContentSpaceBetween">
            <div class="tabletext">指标拟定</div>
        </div> -->
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <div class="flex">
              <div>
                <el-form
                  :model="form"
                  :inline="true"
                  class="form-inline"
                  label-width="120px"
                >
                  <el-form-item label="合同名称">
                    <el-input
                      style="width: 150px"
                      v-model="form.contractName"
                      placeholder="合同名称"
                      :clearable="true"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="受约人姓名">
                    <el-input
                      v-model="form.shouyueName"
                      placeholder="受约人姓名"
                      style="width: 150px"
                      :clearable="true"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="受约人岗位">
                    <el-input
                      v-model="form.shouyueZhiwu"
                      placeholder="受约人岗位"
                      style="width: 150px"
                      :clearable="true"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="受约人职级">
                    <el-input
                      style="width: 150px"
                      v-model="form.ryZjmc"
                      placeholder="受约人职级"
                      :clearable="true"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="发约人姓名">
                    <el-input
                      v-model="form.fayueName"
                      placeholder="发约人姓名"
                      :clearable="true"
                      style="width: 150px"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="状态">
                    <el-select
                      v-model="form.status"
                      placeholder="请选择"
                      :clearable="true"
                      style="width: 150px"
                    >
                      <el-option value="0" label="未提交"></el-option>
                      <el-option value="1" label="已提交"></el-option>
                      <!-- <el-option value="2" label="已驳回"></el-option> -->
                    </el-select>
                  </el-form-item>
                  <el-form-item>
                    <el-button
                      icon="el-icon-search"
                      type="primary"
                      class="marginLeft"
                      @click="search()"
                      >检索</el-button
                    >
                  </el-form-item>
                </el-form>
              </div>
            </div>
          </div>
        </div>
        <div style="border-bottom: 1px solid #b0bde2"></div>
        <div class="flex">
          <div
            class="mt10"
            style="width: 100%; display: flex; justify-content: space-between"
          >
            <div>
              业绩合同
              <span>
                <el-radio v-model="radio" label="1">个人</el-radio>
                <el-radio v-model="radio" label="2">机构</el-radio>
              </span>
              <span
                style="margin-left: 160px"
                v-if="permissions.hetongrenwu_hetonghtxxdjb_scope"
              >
                数据范围
                <el-radio-group v-model="radioTwo">
                  <el-radio
                    v-for="(item, index) in radioTwoList"
                    :label="item.value"
                    :key="index"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </span>
            </div>
            <div>
              <el-button
                style="margin-left: 5px"
                type="primary"
                plain
                @click="enddata"
                v-loading.fullscreen.lock="fullscreenLoadingend"
                >结束</el-button
              >
              <el-button type="primary" plain @click="temanagementBtn"
                >模板管理</el-button
              >
              <el-button
                style="margin-left: 5px"
                type="primary"
                plain
                @click="nidingHz"
                >拟定汇总</el-button
              >
              <el-button
                type="primary"
                plain
                @click="openSubmitAllDialog"
                v-loading.fullscreen.lock="fullscreenLoadingsubmit"
                >提交</el-button
              >
            </div>
          </div>
        </div>
        <el-table
          :data="dataList"
          style="width: 100%; margin-top: 20px"
          border
          v-if="rednermsg"
          v-loading="dataListLoading"
          @selection-change="handleSelectionChange"
          ref="tableRef"
        >
          <el-table-column
            :selectable="checkboxSelect"
            type="selection"
            width="55"
            header-align="center"
            align="center"
          ></el-table-column>
          <el-table-column
            type="index"
            width="60"
            header-align="center"
            align="center"
            label="序号"
          ></el-table-column>
          <el-table-column
            prop="contractName"
            header-align="center"
            align="center"
            min-width="200"
            show-overflow-tooltip
            label="合同名称"
          >
            <template slot-scope="scope">
              <span
                @click="checkDetails(scope.row)"
                style="color: #0e258c; cursor: pointer"
                >{{ scope.row.contractName }}</span
              >
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 2"
            prop="jigouName"
            header-align="center"
            show-overflow-tooltip
            align="center"
            label="机构名称"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.jigouName }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 1"
            prop="shouyueCode"
            header-align="center"
            align="center"
            min-width="150"
            label="受约人编号"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.shouyueCode).slice(
                  0,
                  2
                )"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="cutout(scope.row.shouyueCode).length < 3"
                  effect="dark"
                  :content="scope.row.shouyueCode"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueCode).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueCode).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 1"
            prop="shouyueName"
            header-align="center"
            align="center"
            min-width="120"
            label="受约人姓名"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.shouyueName).slice(
                  0,
                  2
                )"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="cutout(scope.row.shouyueName).length < 3"
                  effect="dark"
                  :content="scope.row.shouyueName"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueName).length > 2 && index === 0
                    "
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 1"
            prop="shouyueDeptName"
            header-align="center"
            align="center"
            min-width="150"
            label="受约人单位"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.shouyueDeptName).slice(
                  0,
                  2
                )"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="cutout(scope.row.shouyueDeptName).length < 3"
                  effect="dark"
                  :content="scope.row.shouyueDeptName"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueDeptName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueDeptName).length > 2 &&
                      index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 1 && shows == 1"
            prop="shouyueZhiwu"
            header-align="center"
            align="center"
            min-width="170"
            label="受约人岗位"
            show-overflow-tooltip
          >
            <template slot="header">
              <el-tooltip placement="top" content="点击切换至受约人职级">
                <span
                  ><i
                    @click="switchBtn(2)"
                    class="el-icon-refresh"
                    style="margin-right: 20px"
                  ></i
                  >受约人岗位</span
                >
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.shouyueZhiwu).slice(
                  0,
                  2
                )"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="cutout(scope.row.shouyueZhiwu).length < 3"
                  effect="dark"
                  :content="scope.row.shouyueZhiwu"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueZhiwu).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueZhiwu).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item | ellipsis }}</span>
                  </el-badge>
                  <span v-else>{{ item | ellipsis }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-if="radio == 1 && shows == 2"
            prop="ryZjmc"
            header-align="center"
            align="center"
            min-width="170"
            label="受约人职级"
          >
            <template slot="header">
              <el-tooltip placement="top" content="点击切换至受约人岗位">
                <span
                  ><i
                    @click="switchBtn(1)"
                    class="el-icon-refresh"
                    style="margin-right: 20px"
                  ></i
                  >受约人职级</span
                >
              </el-tooltip>
            </template>
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.ryZjmc).slice(0, 2)"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="cutout(scope.row.ryZjmc).length < 3"
                  effect="dark"
                  :content="scope.row.ryZjmc"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.ryZjmc).length"
                    :max="9"
                    v-if="cutout(scope.row.ryZjmc).length > 2 && index === 0"
                    class="itembadge"
                  >
                    <span>{{ item | ellipsis }}</span>
                  </el-badge>
                  <span v-else>{{ item | ellipsis }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="fayueName"
            header-align="center"
            align="center"
            min-width="120"
            label="发约人姓名"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.fayueName).slice(0, 2)"
                :key="index"
              >
                <el-tooltip
                  :disabled="cutout(scope.row.fayueName).length < 3"
                  class="item"
                  effect="dark"
                  :content="scope.row.fayueName"
                  placement="top-start"
                >
                  <el-badge
                    :value="cutout(scope.row.fayueName).length"
                    :max="9"
                    v-if="cutout(scope.row.fayueName).length > 2 && index === 0"
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="fayueZhiwu"
            header-align="center"
            align="center"
            min-width="180"
            label="发约人岗位"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in cutout(scope.row.fayueZhiwu).slice(
                  0,
                  2
                )"
                :key="index"
              >
                <el-tooltip
                  class="item"
                  :disabled="
                    item.length < 8 && cutout(scope.row.fayueZhiwu).length < 3
                  "
                  effect="dark"
                  :content="scope.row.fayueZhiwu"
                  placement="top-start"
                >
                  <span>{{
                    (validatenull(item) ? "-" : item) | ellipsis
                  }}</span>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="zhibiaoNum"
            label="指标数量"
            min-width="100"
            header-align="center"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="signLevel"
            label="合同级别"
            min-width="100"
            header-align="center"
            align="center"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.signLevel == '1'">一级合同</span>
              <span v-if="scope.row.signLevel == '2'">二级合同</span>
              <span v-if="scope.row.signLevel == '3'">三级合同</span>
              <span v-if="scope.row.signLevel == '4'">四级合同</span>
              <span v-if="scope.row.signLevel == '5'">五级合同</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="status"
            label="状态"
            min-width="120"
            header-align="center"
            align="center"
          >
            <template slot-scope="scope">
              <el-popover placement="left" width="380" trigger="hover">
                <p>{{ scope.row.fayueName }}</p>
                <el-table :data="scope.row.gridData">
                  <el-table-column
                    width="90"
                    property="zbname"
                    label="指标名称"
                    show-overflow-tooltip
                  ></el-table-column>
                  <el-table-column
                    width="90"
                    property="name"
                    label="姓名"
                  ></el-table-column>
                  <el-table-column
                    width="90"
                    property="zhiwu"
                    label="职务"
                  ></el-table-column>
                  <el-table-column width="90" property="status" label="状态">
                    <template slot-scope="smallScope">
                      <span v-if="smallScope.row.status == '1'">填报中</span>
                      <span v-if="smallScope.row.status == '2'">审核中</span>
                      <span v-if="smallScope.row.status == '3'">已审核</span>
                      <span v-if="smallScope.row.status == '4'">审核驳回</span>
                    </template>
                  </el-table-column>
                </el-table>
                <div slot="reference" class="name-wrapper">
                  <span v-if="scope.row.status == 0">未提交</span>
                  <span v-if="scope.row.status == 1">已提交</span>
                  <span v-if="scope.row.status == 2">已驳回</span>
                </div>
              </el-popover>
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            v-if="rowStatus"
            width="200"
            header-align="center"
            align="center"
            fixed="right"
          >
            <template slot-scope="scope">
              <div style="display: none">
                {{ (rowStatus = scope.row.status == 0 ? true : false) }}
              </div>
              <el-button
                type="primary"
                plain
                v-if="scope.row.status == 0"
                @click="submit(scope.row)"
                >提交</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <el-dialog title="请选择：" :visible.sync="chooseVisible" width="30%">
        <div style="display: flex; justify-content: space-around">
          <el-button type="warning" @click="customBtn">自定义流程</el-button>
          <el-dropdown>
            <el-button type="primary" size="small" v-if="temList.length > 0">
              模板<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-button type="primary" size="small" v-else> 暂无模板 </el-button>
            <el-dropdown-menu v-show="temList.length > 0">
              <el-dropdown-item v-for="(item, index) in temList" :key="index"
                ><span
                  @click="temBtn(item)"
                  v-loading.fullscreen.lock="fullscreenLoading"
                  >{{ item.templateName }}</span
                ></el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-dialog>
      <temanagementDialog
        :temanagementDialogData="temanagementDialogData"
      ></temanagementDialog>
      <sortingPerChooseDialog
        :sortingPerChooseDialogData="sortingPerChooseDialogData"
        @sortingPerChooseDialogChild="sortingPerChooseDialogChild"
      ></sortingPerChooseDialog>
      <zhibiaoForm
        ref="zhibiaoFormRef"
        v-if="zhiShow == 2"
        :zhibiaoForm="zhibiaoForm"
        :hetong="hetong"
        :hetongId="hetongId"
        :contractName="contractName"
        v-on:zhibiaoChild="zhibiaoChild"
      ></zhibiaoForm>
      <!--      拟定汇总-->
      <TianBaoTable
        v-if="zhiShow == 3"
        ref="tianbaotable"
        :tianBaoTable="tianBaoTable"
        :ids="ids"
        :radio="radio"
        @fnBackOldPage="fnBackOldPage"
        :ndids="ndids"
      ></TianBaoTable>
      <customDialog
        :customDialogData="customDialogData"
        @customDialogChildren="customDialogChildren"
      ></customDialog>
    </basic-container>
  </div>
</template>

<script>
import zhibiaoForm from "@/views/hetongrenwu/components/zhibiao-form.vue";
import TianBaoTable from "@/views/hetongrenwu/components/htndhuizong-table.vue";
import {
  fetchList,
  submitStatus,
  submitStatusAll,
  confirmMubiao,
  submitStatusAllfn,
  endTask,
  isflagzhibiao,
} from "@/api/hetongrenwu/hetongyeji/hetongnd";
import { mapGetters } from "vuex";
import { getListMb } from "@/api/hetongrenwu/hetongjgtb";
import { radioTwoList } from "@/api/hetongrenwu/hetonghtxxdjb";
import { validatenull } from "@/util/validate";
import sortingPerChooseDialog from "@/views/hetongrenwu/components/sortingPerChooseDialog.vue";
import temanagementDialog from "./temanagementDialog";
import customDialog from "./customDialog";

export default {
  components: {
    zhibiaoForm,
    TianBaoTable,
    sortingPerChooseDialog,
    temanagementDialog,
    customDialog,
  },
  data() {
    return {
      hetong: {},
      hetongId: Number,
      dataListLoading: false,
      rowStatus: false,
      form: {},
      sortingPerChooseDialogData: {},
      temanagementDialog: {},
      radio: "1",
      radioTwo: "-1",
      dataList: [],
      ndids: [],
      temList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      zhiShow: 1,
      zhibiaoForm: {},
      fullscreenLoading: false,
      fullscreenLoadingsubmit: false,
      temanagementDialogData: {},
      searchadvanced: true,
      searchheight: "0",
      radioTwoList: radioTwoList,
      tianBaoTable: {},
      ids: [],
      contractName: "",
      dialogVisiblePiLiang: false,
      pilinangform: {},
      ryZjmc: "",
      chooseVisible: false,
      customDialogData: {},
      type: Number,
      iszbsh: Number,
      fullscreenLoadingend: false,
      shows: 1,
      rednermsg: true,
    };
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
  },
  watch: {
    radio(value) {
      if (value) {
        this.getDataList();
      }
    },
    radioTwo(value) {
      if (value) {
        this.getDataList();
      }
    },
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    switchBtn(e) {
      this.shows = e;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    //搜索
    search() {
      this.getDataList();
    },
    //获取合同列表
    getDataList() {
      this.dataListLoading = true;
      fetchList(
        Object.assign({
          type: this.radio,
          isbenbu: this.radioTwo,
          shouyueName: this.form.shouyueName,
          fayueName: this.form.fayueName,
          shouyueZhiwu: this.form.shouyueZhiwu,
          ryZjmc: this.form.ryZjmc,
          status: this.form.status,
          current: this.pageIndex,
          size: this.pageSize,
          contractName: this.form.contractName,
          tagName: "业绩合同",
        })
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    fngetListMb() {
      var params = {
        menuType: "指标拟定",
        tagName: "业绩合同",
      };
      getListMb(params).then((res) => {
        this.temList = res.data.data;
      });
    },
    //提交
    submit(row) {
      this.$confirm("是否要提交该条数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          submitStatus(row.id)
            .then((res) => {
              this.$message.closeAll();
              this.$message({
                type: "success",
                message: "提交成功!",
              });
              this.getDataList();
            })
            .catch(() => {
              this.$message.closeAll();
              this.$message({
                type: "error",
                message: "提交失败!",
              });
            });
        })
        .catch(() => {
          this.$message.closeAll();
          this.$message({
            type: "info",
            message: "已取消提交",
          });
        });
      this.getDataList();
    },
    enddata() {
      var rowsarr = [];
      const rows = this.$refs.tableRef.selection;
      if (rows.length == 0) {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请至少选择一条数据结束!",
        });
        return false;
      }
      rowsarr = this.$refs.tableRef.selection;
      var params = {
        rows: rowsarr,
      };
      isflagzhibiao(params).then((response) => {
        if (response.data.data) {
          this.$confirm("是否结束当前指标！", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.fullscreenLoadingend = true;
            endTask(params)
              .then((res) => {
                this.$message.closeAll();
                this.$message.success("结束成功");
                this.getDataList();
                this.fullscreenLoadingend = false;
              })
              .catch(() => {
                this.$message.closeAll();
                this.$message({
                  type: "error",
                  message: "提交失败!",
                });
                this.fullscreenLoadingend = false;
              });
          });
        } else {
          this.$message.closeAll();
          this.$message({
            type: "error",
            message: "已存在指标,不能结束！",
          });
        }
      });
    },
    //打开批量提交弹框
    openSubmitAllDialog() {
      var rowsarr = this.$refs.tableRef.selection;
      if (rowsarr.length == 0) {
        this.$message.closeAll();
        this.$message({
          type: "info",
          message: "请至少选择一条数据提交!",
        });
        return false;
      }
      for (var i = 0; i < rowsarr.length; i++) {
        if (rowsarr[i].zhibiaoNum == 0) {
          this.$message.warning(
            "勾选的的的第" + [i] + "条没有指标，不允许提交"
          );
          return;
        }
      }
      var params = {
        rows: rowsarr,
      };
      confirmMubiao(params).then((response) => {
        if (response.data.data) {
          this.$confirm("是否跳过指标审核", "提示", {
            confirmButtonText: "是",
            cancelButtonText: "否",
            type: "warning",
          })
            .then((res) => {
              this.fullscreenLoadingsubmit = true;
              this.iszbsh = 0;
              const rows = this.$refs.tableRef.selection;
              var params = {
                iszbsh: 0,
                rows: rows,
              };
              submitStatusAll(params)
                .then((res) => {
                  this.$message.closeAll();
                  this.$message.success("提交成功");
                  this.getDataList();
                  this.fullscreenLoadingsubmit = false;
                })
                .catch(() => {
                  this.$message.closeAll();
                  this.$message({
                    type: "error",
                    message: "提交失败!",
                  });
                  this.fullscreenLoadingsubmit = false;
                });
            })
            .catch((res) => {
              this.iszbsh = 1;
              this.chooseVisible = true;
              this.fngetListMb();
            });
        } else {
          this.$confirm(
            "选中数据存在指标目标值或权重为空的情况，是否继续提交",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          ).then(() => {
            this.$confirm("是否跳过指标审核", "提示", {
              confirmButtonText: "是",
              cancelButtonText: "否",
              type: "warning",
            })
              .then((res) => {
                this.iszbsh = 0;
                const rows = this.$refs.tableRef.selection;
                var params = {
                  iszbsh: 0,
                  rows: rows,
                };
                submitStatusAll(params)
                  .then((res) => {
                    this.$message.closeAll();
                    this.$message.success("提交成功");
                  })
                  .catch(() => {
                    this.$message.closeAll();
                    this.$message({
                      type: "error",
                      message: "提交失败!",
                    });
                  });
                this.getDataList();
              })
              .catch(() => {
                this.iszbsh = 1;
                this.chooseVisible = true;
                this.fngetListMb();
              });
          });
        }
      });
    },
    customBtn() {
      this.chooseVisible = false;
      this.type = 2;
      this.customDialogData = {
        dialogVisible: true,
        type: this.type,
        iszbsh: this.iszbsh,
        rows: this.$refs.tableRef.selection,
        menuType: "zbnd",
      };
    },
    temBtn(e) {
      this.fullscreenLoading = true;
      this.type = 1;
      var params = {
        type: this.type,
        iszbsh: this.iszbsh,
        rows: this.$refs.tableRef.selection,
        templateId: e.id,
      };
      submitStatusAllfn(params).then((res) => {
        this.fullscreenLoading = false;
        this.$message.closeAll();
        this.$message.success("操作成功");
        this.chooseVisible = false;
        this.getDataList();
      });
    },
    sortingPerChooseDialogChild(data) {
      this.getDataList();
    },
    temanagementBtn() {
      this.temanagementDialogData = {
        dialogVisible: true,
        type: "指标拟定",
      };
    },
    //编辑查看
    checkDetails(row) {
      this.zhiShow = 2;
      this.hetongId = row.htId;
      this.hetong = row;
      this.contractName = row.contractName;
      this.zhibiaoForm = {
        enter: 1,
        disabled: false,
        formName: "zbnd",
        status: row.status, //根据合同状态决定指标是否可编辑
        ndUserId: row.ndUserId, //根据合同状态决定指标是否可编辑
        tgLx: row.tgLx, //根据该状态决定数据提供显示的是部门还是人，1为机构，2为人
        id: row.id,
        rows: row,
      };
      this.$nextTick(() => {
        this.$refs.zhibiaoFormRef.getDataList();
      });
    },
    //子集信息
    zhibiaoChild(zhibiaoChild) {
      if (zhibiaoChild) {
        this.zhiShow = 1;
        this.getDataList();
      }
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    checkboxSelect(row, rowIndex) {
      if (row.status != 1) {
        return true;
      } else {
        return false;
      }
    },
    //拆分数据
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    //判空
    validatenull(val) {
      return validatenull(val);
    },
    nidingHz() {
      if (this.$refs.tableRef.selection.length < 1) {
        this.$message.closeAll();
        this.$message.error("请至少选中一条合同");
        return;
      }
      if (this.multipleSelection != undefined) {
        var ids = this.multipleSelection.map((item) => {
          return item.htId;
        });
        this.ids = ids;
        var ndids = this.multipleSelection.map((item) => {
          return item.id;
        });
        this.ndids = ndids;
      } else {
        var ids = this.$refs.tableRef.data.map((item) => {
          return item.htId;
        });
        this.ids = ids;
        var ndids = this.$refs.tableRef.data.map((item) => {
          return item.id;
        });
        this.ndids = ndids;
      }

      this.zhiShow = 3;
      this.tianBaoTable = {
        lastPage: "zbnd",
      };
    },
    fnBackOldPage(data) {
      this.zhiShow = 1;
      this.ids = [];
      this.multipleSelection = undefined;
      this.getDataList();
    },
    handleSelectionChange(rows) {
      this.multipleSelection = rows;
    },
    customDialogChildren(data) {
      this.getDataList();
    },
  },
};
</script>

<style>
</style>
